<template>
  <transition name="el-zoom-in-center">
    <div class="JNPF-preview-main">
      <div class="JNPF-common-page-header">
        <el-page-header @back="goBack"
                        :content="!dataForm.id ? '新建':'编辑'"/>
        <div class="options">
          <el-button type="primary" @click="dataFormSubmit()" :loading="btnLoading" :disabled='continueBtnLoading'> 保
            存
          </el-button>
          <el-button @click="goBack"> 取 消</el-button>
        </div>
      </div>
      <el-row :gutter="15" class=" main" :style="{margin: '0 auto',width: '100%'}">
        <el-form ref="formRef" :model="dataForm" :rules="dataRule" size="small" label-width="100px"
                 label-position="left">
          <template v-if="!loading">
            <!-- 具体表单 -->
            <el-col :span="4">
              <el-row :gutter="15">
                <el-col :span="24">
                  <jnpf-form-tip-item>
                    <JnpfText
                      :textStyle='{"color":"#000000","font-weight":"normal","text-decoration":"none","font-size":12,"line-height":32,"font-style":"normal","text-align":"left"}'>
                    </JnpfText>
                  </jnpf-form-tip-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="16">
              <el-row :gutter="15">
                <el-col :span="24">
                  <jnpf-form-tip-item>
                    <JnpfText
                      :textStyle='{"color":"#000000","font-weight":"bold","text-decoration":"none","font-size":18,"line-height":32,"font-style":"normal","text-align":"center"}'
                      content="看样学样">
                    </JnpfText>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item>
                    <JnpfGroupTitle
                      content="一、企业基础信息" contentPosition="left">
                    </JnpfGroupTitle>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="12">
                  <el-row :gutter="15">
                    <el-col :span="24">
                      <jnpf-form-tip-item
                        label="所属区域" prop="region">
                        <JnpfSelect v-model="dataForm.region" @change="changeData('region',-1)"
                                    placeholder="请选择" clearable :style='{"width":"100%"}' :options="regionOptions"
                                    :props="regionProps">
                        </JnpfSelect>
                      </jnpf-form-tip-item>
                    </el-col>
                    <el-col :span="24">
                      <jnpf-form-tip-item
                        label="所属行业" prop="industry">
                        <JnpfCascader v-model="dataForm.industry" @change="changeData('industry',-1)"
                                      placeholder="请选择" show-all-levels clearable :style='{"width":"100%"}'
                                      separator="/" :options="industryOptions" :props="industryProps">
                        </JnpfCascader>
                      </jnpf-form-tip-item>
                    </el-col>
                    <el-col :span="24">
                      <jnpf-form-tip-item
                        label="企业名称" prop="companyname">
                        <JnpfInput v-model="dataForm.companyname" @change="changeData('companyname',-1)"
                                   placeholder="请输入" clearable :style='{"width":"100%"}'>
                        </JnpfInput>
                      </jnpf-form-tip-item>
                    </el-col>
                  </el-row>
                </el-col>
                <el-col :span="12">
                  <jnpf-form-tip-item
                    label="相关图片" prop="pic">
                    <JnpfUploadImg v-model="dataForm.pic" @change="changeData('pic',-1)"
                                   :fileSize="10" sizeUnit="MB" :limit="9" pathType="defaultPath" :isAccount="0">
                    </JnpfUploadImg>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="企业简介" prop="gaicompanyinfo">
                    <JnpfEditor v-model="dataForm.gaicompanyinfo" @change="changeData('gaicompanyinfo',-1)"
                                placeholder="请输入" :style='{"width":"100%"}'>
                    </JnpfEditor>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item>
                    <JnpfGroupTitle
                      content="二、项目背景" contentPosition="left">
                    </JnpfGroupTitle>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="改造前数字化水平等级" label-width="170px" prop="levelbefore">
                    <JnpfSelect v-model="dataForm.levelbefore" @change="changeData('levelbefore',-1)"
                                placeholder="请选择" clearable :style='{"width":"100%"}' :options="levelbeforeOptions"
                                :props="levelbeforeProps">
                    </JnpfSelect>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="改造前数字化现状" label-width="130px" prop="infobefore">
                    <JnpfEditor v-model="dataForm.infobefore" @change="changeData('infobefore',-1)"
                                placeholder="请输入" :style='{"width":"100%"}'>
                    </JnpfEditor>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="数字化改造需求" label-width="110px" prop="digitalrequire">
                    <JnpfEditor v-model="dataForm.digitalrequire" @change="changeData('digitalrequire',-1)"
                                placeholder="请输入" :style='{"width":"100%"}'>
                    </JnpfEditor>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item>
                    <JnpfGroupTitle
                      content="三、企业数字化改造项目实施" contentPosition="left">
                    </JnpfGroupTitle>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="项目名称" prop="projectname">
                    <JnpfInput v-model="dataForm.projectname" @change="changeData('projectname',-1)"
                               placeholder="请输入" clearable :style='{"width":"100%"}'>
                    </JnpfInput>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="项目内容" prop="projectinfo">
                    <JnpfEditor v-model="dataForm.projectinfo" @change="changeData('projectinfo',-1)"
                                placeholder="请输入" :style='{"width":"100%"}'>
                    </JnpfEditor>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="合作数字化服务商" label-width="125px" prop="cooperationdigitalserver">
                    <JnpfTextarea v-model="dataForm.cooperationdigitalserver"
                                  @change="changeData('cooperationdigitalserver',-1)"
                                  placeholder="请输入" :style='{"width":"100%"}' true type="textarea"
                                  :autosize='{"minRows":4,"maxRows":4}'>
                    </JnpfTextarea>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item>
                    <JnpfGroupTitle
                      content="四、项目实施效果" contentPosition="left">
                    </JnpfGroupTitle>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="(预期)改造后数字化水平等级" label-width="210px" prop="levelafter">
                    <JnpfSelect v-model="dataForm.levelafter" @change="changeData('levelafter',-1)"
                                placeholder="请选择" clearable :style='{"width":"100%"}' :options="levelafterOptions"
                                :props="levelafterProps">
                    </JnpfSelect>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item
                    label="改造后数字化情况" label-width="130px" prop="infoafter">
                    <JnpfEditor v-model="dataForm.infoafter" @change="changeData('infoafter',-1)"
                                placeholder="请输入" :style='{"width":"100%"}'>
                    </JnpfEditor>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="12">
                  <jnpf-form-tip-item
                    label="服务商名称" prop="enterprisenmae">
                    <JnpfInput v-model="dataForm.enterprisenmae" @change="changeData('enterprisenmae',-1)"
                               placeholder="请输入" clearable :style='{"width":"100%"}'>
                    </JnpfInput>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="12">
                  <jnpf-form-tip-item
                    label="信用代码" prop="enterprisecreditcode">
                    <JnpfInput v-model="dataForm.enterprisecreditcode" @change="changeData('enterprisecreditcode',-1)"
                               placeholder="请输入" clearable :style='{"width":"100%"}'>
                    </JnpfInput>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="12">
                  <jnpf-form-tip-item
                    label="创建用户" prop="creatoruserid">
                    <JnpfOpenData v-model="dataForm.creatoruserid" @change="changeData('creatoruserid',-1)"
                                  placeholder="系统自动生成" readonly :style='{"width":"100%"}' type="currUser">
                    </JnpfOpenData>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="12">
                  <jnpf-form-tip-item
                    label="创建时间" prop="creatortime">
                    <JnpfOpenData v-model="dataForm.creatortime" @change="changeData('creatortime',-1)"
                                  placeholder="系统自动生成" readonly :style='{"width":"100%"}' type="currTime">
                    </JnpfOpenData>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="12">
                  <jnpf-form-tip-item
                    label="修改用户" prop="lastmodifyuserid">
                    <JnpfInput v-model="dataForm.lastmodifyuserid" @change="changeData('lastmodifyuserid',-1)"
                               placeholder="系统自动生成" readonly :style='{"width":"100%"}'>
                    </JnpfInput>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="12">
                  <jnpf-form-tip-item
                    label="修改时间" prop="lastmodifytime">
                    <JnpfInput v-model="dataForm.lastmodifytime" @change="changeData('lastmodifytime',-1)"
                               placeholder="系统自动生成" readonly :style='{"width":"100%"}'>
                    </JnpfInput>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item label-width="0">
                    <div class="JNPF-common-title">
                      <h2>设计子表</h2>
                    </div>
                    <el-table :data="dataForm.fz_learn_example_clickList" size='mini'>
                      <el-table-column type="index" width="50" label="序号" align="center"/>
                      <el-table-column
                        label="点击用户" prop="clickUser">
                        <template slot="header" v-if="false">
                          <span class="required-sign">*</span>点击用户
                        </template>
                        <template slot-scope="scope">
                          <JnpfInput v-model="scope.row.clickUser"
                                     @change="changeData('fz_learn_example_click-clickUser',scope.$index)"
                                     placeholder="请输入" clearable :style='{"width":"100%"}'>
                          </JnpfInput>
                        </template>
                      </el-table-column>
                      <el-table-column label="操作" width="50">
                        <template slot-scope="scope">
                          <el-button size="mini" type="text" class="JNPF-table-delBtn"
                                     @click="delfz_learn_example_clickList(scope.$index)">删除
                          </el-button>
                        </template>
                      </el-table-column>
                    </el-table>
                    <div class="table-actions" @click="addfz_learn_example_clickList()">
                      <el-button type="text" icon="el-icon-plus">添加</el-button>
                    </div>
                  </jnpf-form-tip-item>
                </el-col>
                <el-col :span="24">
                  <jnpf-form-tip-item label-width="0">
                    <div class="JNPF-common-title">
                      <h2>设计子表</h2>
                    </div>
                    <el-table :data="dataForm.fz_learn_example_taskList" size='mini'>
                      <el-table-column type="index" width="50" label="序号" align="center"/>
                      <el-table-column
                        label="状态" prop="status">
                        <template slot="header" v-if="false">
                          <span class="required-sign">*</span>状态
                        </template>
                        <template slot-scope="scope">
                          <JnpfInput v-model="scope.row.status"
                                     @change="changeData('fz_learn_example_task-status',scope.$index)"
                                     placeholder="请输入" clearable :style='{"width":"100%"}'>
                          </JnpfInput>
                        </template>
                      </el-table-column>
                      <el-table-column label="操作" width="50">
                        <template slot-scope="scope">
                          <el-button size="mini" type="text" class="JNPF-table-delBtn"
                                     @click="delfz_learn_example_taskList(scope.$index)">删除
                          </el-button>
                        </template>
                      </el-table-column>
                    </el-table>
                    <div class="table-actions" @click="addfz_learn_example_taskList()">
                      <el-button type="text" icon="el-icon-plus">添加</el-button>
                    </div>
                  </jnpf-form-tip-item>
                </el-col>
              </el-row>
            </el-col>
            <el-col :span="4">
              <el-row :gutter="15">
                <el-col :span="24">
                  <jnpf-form-tip-item>
                    <JnpfText
                      :textStyle='{"color":"#000000","font-weight":"normal","text-decoration":"none","font-size":12,"line-height":32,"font-style":"normal","text-align":"left"}'>
                    </JnpfText>
                  </jnpf-form-tip-item>
                </el-col>
              </el-row>
            </el-col>
            <!-- 表单结束 -->
          </template>
        </el-form>
        <SelectDialog v-if="selectDialogVisible" :config="currTableConf" :formData="dataForm"
                      ref="selectDialog" @select="addForSelect" @close="selectDialogVisible=false"/>
      </el-row>
    </div>
  </transition>
</template>


<script>
import request from '@/utils/request'
import {mapGetters} from "vuex";
import {getDataInterfaceRes} from '@/api/systemData/dataInterface'
import {getDictionaryDataSelector} from '@/api/systemData/dictionary'
import {getDefaultCurrentValueUserId} from '@/api/permission/user'
import {getDefaultCurrentValueDepartmentId} from '@/api/permission/organize'
import {
  getDateDay,
  getLaterData,
  getBeforeData,
  getBeforeTime,
  getLaterTime
} from '@/components/Generator/utils/index.js'
import {thousandsFormat} from "@/components/Generator/utils/index"

export default {
  components: {},
  props: [],
  data() {
    return {
      dataFormSubmitType: 0,
      continueBtnLoading: false,
      index: 0,
      prevDis: false,
      nextDis: false,
      allList: [],
      visible: false,
      loading: false,
      btnLoading: false,
      formRef: 'formRef',
      setting: {},
      eventType: '',
      userBoxVisible: false,
      selectDialogVisible: false,
      currTableConf: {},
      dataValueAll: {},
      addTableConf: {
        fz_learn_example_clickList: {
          "popupType": "dialog",
          "hasPage": true,
          "popupTitle": "选择数据",
          "pageSize": 20,
          "columnOptions": [],
          "interfaceId": "",
          "interfaceName": "",
          "relationOptions": [],
          "templateJson": [],
          "popupWidth": "800px"
        },
        fz_learn_example_taskList: {
          "popupType": "dialog",
          "hasPage": true,
          "popupTitle": "选择数据",
          "pageSize": 20,
          "columnOptions": [],
          "interfaceId": "",
          "interfaceName": "",
          "relationOptions": [],
          "templateJson": [],
          "popupWidth": "800px"
        },
      },
      //可选范围默认值
      ableAll: {},
      tableRows: {
        fz_learn_example_clickList: {
          clickUser: '',
          clickUserOptions: [],
          enabledmark: undefined
        },
        fz_learn_example_taskList: {
          status: '',
          statusOptions: [],
          enabledmark: undefined
        },
      },
      Vmodel: "",
      currVmodel: "",
      dataForm: {
        region: undefined,
        industry: [],
        companyname: undefined,
        pic: [],
        gaicompanyinfo: undefined,
        levelbefore: undefined,
        infobefore: undefined,
        digitalrequire: undefined,
        projectname: undefined,
        projectinfo: undefined,
        cooperationdigitalserver: undefined,
        levelafter: undefined,
        infoafter: undefined,
        enterprisenmae: undefined,
        enterprisecreditcode: undefined,
        creatoruserid: undefined,
        creatortime: undefined,
        lastmodifyuserid: undefined,
        lastmodifytime: undefined,
        fz_learn_example_clickList: [],
        fz_learn_example_taskList: [],
      },
      tableRequiredData: {},
      dataRule:
        {},
      regionOptions: [],
      regionProps: {"label": "fullName", "value": "id"},
      industryOptions: [],
      industryProps: {"label": "fullName", "value": "id", "children": "children"},
      levelbeforeOptions: [{"fullName": "无等级", "id": "0"}, {"fullName": "一级", "id": "1"}, {
        "fullName": "二级",
        "id": "2"
      }, {"fullName": "三级", "id": "3"}, {"fullName": "四级", "id": "4"}, {"fullName": "五级", "id": "5"}],
      levelbeforeProps: {"label": "fullName", "value": "id"},
      levelafterOptions: [{"fullName": "无等级", "id": "0"}, {"fullName": "一级", "id": "1"}, {
        "fullName": "二级",
        "id": "2"
      }, {"fullName": "三级", "id": "3"}, {"fullName": "四级", "id": "4"}, {"fullName": "五级", "id": "5"}],
      levelafterProps: {"label": "fullName", "value": "id"},
      childIndex: -1,
      isEdit: false,
      interfaceRes: {
        region: [],
        industry: [],
        companyname: [],
        pic: [],
        gaicompanyinfo: [],
        levelbefore: [],
        infobefore: [],
        digitalrequire: [],
        projectname: [],
        projectinfo: [],
        cooperationdigitalserver: [],
        levelafter: [],
        infoafter: [],
        enterprisenmae: [],
        enterprisecreditcode: [],
        creatoruserid: [],
        creatortime: [],
        lastmodifyuserid: [],
        lastmodifytime: [],
        fz_learn_example_clickclickUser: [],
        fz_learn_example_taskstatus: [],
      },
    }
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  watch: {},
  created() {
    this.dataAll()
    this.initDefaultData()
    this.dataValueAll = JSON.parse(JSON.stringify(this.dataForm))
  },
  mounted() {
  },
  methods: {
    prev() {
      this.index--
      if (this.index === 0) {
        this.prevDis = true
      }
      this.nextDis = false
      for (let index = 0; index < this.allList.length; index++) {
        const element = this.allList[index];
        if (this.index == index) {
          this.getInfo(element.id)
        }
      }
    },
    next() {
      this.index++
      if (this.index === this.allList.length - 1) {
        this.nextDis = true
      }
      this.prevDis = false
      for (let index = 0; index < this.allList.length; index++) {
        const element = this.allList[index];
        if (this.index == index) {
          this.getInfo(element.id)
        }
      }
    },
    getInfo(id) {
      request({
        url: '/api/example/Fz_learn_example/' + id,
        method: 'get'
      }).then(res => {
        this.dataInfo(res.data)
      });
    },
    goBack() {
      this.visible = false
      this.$emit('refreshDataList', true)
    },
    changeData(model, index) {
      this.isEdit = false
      this.childIndex = index
      let modelAll = model.split("-");
      let faceMode = "";
      for (let i = 0; i < modelAll.length; i++) {
        faceMode += modelAll[i];
      }
      for (let key in this.interfaceRes) {
        if (key != faceMode) {
          let faceReList = this.interfaceRes[key]
          for (let i = 0; i < faceReList.length; i++) {
            if (faceReList[i].relationField == model) {
              let options = 'get' + key + 'Options';
              if (this[options]) {
                this[options]()
              }
              this.changeData(key, index)
            }
          }
        }
      }
    },
    changeDataFormData(type, data, model, index, defaultValue) {
      if (!this.isEdit) {
        if (type == 2) {
          for (let i = 0; i < this.dataForm[data].length; i++) {
            if (index == -1) {
              this.dataForm[data][i][model] = defaultValue
            } else if (index == i) {
              this.dataForm[data][i][model] = defaultValue
            }
          }
        } else {
          this.dataForm[data] = defaultValue
        }
      }
    },
    dataAll() {
      this.getregionOptions();
      this.getindustryOptions();
    },
    fz_learn_example_clickExist() {
      let isOk = true;
      for (let i = 0; i < this.dataForm.fz_learn_example_clickList.length; i++) {
        const e = this.dataForm.fz_learn_example_clickList[i];
      }
      return isOk;
    },
    fz_learn_example_taskExist() {
      let isOk = true;
      for (let i = 0; i < this.dataForm.fz_learn_example_taskList.length; i++) {
        const e = this.dataForm.fz_learn_example_taskList[i];
      }
      return isOk;
    },
    getregionOptions() {
      getDictionaryDataSelector('487278954734944325').then(res => {
        this.regionOptions = res.data.list
      })
    },
    getindustryOptions() {
      getDictionaryDataSelector('523125631823643269').then(res => {
        this.industryOptions = res.data.list
      })
    },
    goBack() {
      this.$emit('refresh')
    },
    clearData() {
      this.dataForm = JSON.parse(JSON.stringify(this.dataValueAll))
    },
    init(id, isDetail, allList) {
      this.prevDis = false
      this.nextDis = false
      this.allList = allList || []
      if (allList.length) {
        this.index = this.allList.findIndex(item => item.id === id)
        if (this.index == 0) {
          this.prevDis = true
        }
        if (this.index == this.allList.length - 1) {
          this.nextDis = true
        }
      } else {
        this.prevDis = true
        this.nextDis = true
      }
      this.dataForm.id = id || 0;
      this.visible = true;
      this.$nextTick(() => {
        if (this.dataForm.id) {
          this.loading = true
          request({
            url: '/api/example/Fz_learn_example/' + this.dataForm.id,
            method: 'get'
          }).then(res => {
            this.dataInfo(res.data)
            this.loading = false
          });
        } else {
          this.clearData()
          this.initDefaultData()
        }
      });
      this.$store.commit('generator/UPDATE_RELATION_DATA', {})
    },
    //初始化默认数据
    initDefaultData() {

    },
    // 表单提交
    dataFormSubmit(type) {
      this.dataFormSubmitType = type ? type : 0
      this.$refs['formRef'].validate((valid) => {
        if (valid) {
          if (!this.fz_learn_example_clickExist()) return
          if (!this.fz_learn_example_taskExist()) return
          this.request()
        }
      })
    },
    request() {
      let _data = this.dataList()
      if (this.dataFormSubmitType == 2) {
        this.continueBtnLoading = true
      } else {
        this.btnLoading = true
      }
      if (!this.dataForm.id) {
        request({
          url: '/api/example/Fz_learn_example',
          method: 'post',
          data: _data
        }).then((res) => {
          this.$message({
            message: res.msg,
            type: 'success',
            duration: 1000,
            onClose: () => {
              if (this.dataFormSubmitType == 2) {
                this.$nextTick(() => {
                  this.clearData()
                  this.initDefaultData()
                })
                this.continueBtnLoading = false
                return
              }
              this.visible = false
              this.btnLoading = false
              this.$emit('refresh', true)
            }
          })
        }).catch(() => {
          this.btnLoading = false
          this.continueBtnLoading = false
        })
      } else {
        request({
          url: '/api/example/Fz_learn_example/' + this.dataForm.id,
          method: 'PUT',
          data: _data
        }).then((res) => {
          this.$message({
            message: res.msg,
            type: 'success',
            duration: 1000,
            onClose: () => {
              if (this.dataFormSubmitType == 2) return this.continueBtnLoading = false
              this.visible = false
              this.btnLoading = false
              this.$emit('refresh', true)
            }
          })
        }).catch(() => {
          this.btnLoading = false
          this.continueBtnLoading = false
        })
      }
    },
    addfz_learn_example_clickList() {
      let item = {
        clickUser: undefined,
      }
      this.getfz_learn_example_clickList(item)
    },
    delfz_learn_example_clickList(index) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        type: 'warning'
      }).then(() => {
        this.dataForm.fz_learn_example_clickList.splice(index, 1);
      }).catch(() => {
      });
    },
    getfz_learn_example_clickList(value) {
      let item = {...this.tableRows.fz_learn_example_clickList, ...value}
      this.dataForm.fz_learn_example_clickList.push(item)
      this.childIndex = this.dataForm.fz_learn_example_clickList.length - 1
      this.isEdit = true
      this.isEdit = false
      this.childIndex = -1
    },
    addfz_learn_example_taskList() {
      let item = {
        status: undefined,
      }
      this.getfz_learn_example_taskList(item)
    },
    delfz_learn_example_taskList(index) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        type: 'warning'
      }).then(() => {
        this.dataForm.fz_learn_example_taskList.splice(index, 1);
      }).catch(() => {
      });
    },
    getfz_learn_example_taskList(value) {
      let item = {...this.tableRows.fz_learn_example_taskList, ...value}
      this.dataForm.fz_learn_example_taskList.push(item)
      this.childIndex = this.dataForm.fz_learn_example_taskList.length - 1
      this.isEdit = true
      this.isEdit = false
      this.childIndex = -1
    },
    openSelectDialog(key) {
      this.currTableConf = this.addTableConf[key]
      this.currVmodel = key
      this.selectDialogVisible = true
      this.$nextTick(() => {
        this.$refs.selectDialog.init()
      })
    },
    addForSelect(data) {
      for (let i = 0; i < data.length; i++) {
        let t = data[i]
        if (this['get' + this.currVmodel]) {
          this['get' + this.currVmodel](t)
        }
      }
    },
    dateTime(timeRule, timeType, timeTarget, timeValueData, dataValue) {
      let timeDataValue = null;
      let timeValue = Number(timeValueData)
      if (timeRule) {
        if (timeType == 1) {
          timeDataValue = timeValue
        } else if (timeType == 2) {
          timeDataValue = dataValue
        } else if (timeType == 3) {
          timeDataValue = new Date().getTime()
        } else if (timeType == 4) {
          let previousDate = '';
          if (timeTarget == 1 || timeTarget == 2) {
            previousDate = getDateDay(timeTarget, timeType, timeValue)
            timeDataValue = new Date(previousDate).getTime()
          } else if (timeTarget == 3) {
            previousDate = getBeforeData(timeValue)
            timeDataValue = new Date(previousDate).getTime()
          } else {
            timeDataValue = getBeforeTime(timeTarget, timeValue).getTime()
          }
        } else if (timeType == 5) {
          let previousDate = '';
          if (timeTarget == 1 || timeTarget == 2) {
            previousDate = getDateDay(timeTarget, timeType, timeValue)
            timeDataValue = new Date(previousDate).getTime()
          } else if (timeTarget == 3) {
            previousDate = getLaterData(timeValue)
            timeDataValue = new Date(previousDate).getTime()
          } else {
            timeDataValue = getLaterTime(timeTarget, timeValue).getTime()
          }
        }
      }
      return timeDataValue;
    },
    time(timeRule, timeType, timeTarget, timeValue, formatType, dataValue) {
      let format = formatType == 'HH:mm' ? 'HH:mm:00' : formatType
      let timeDataValue = null
      if (timeRule) {
        if (timeType == 1) {
          timeDataValue = timeValue || '00:00:00'
          if (timeDataValue.split(':').length == 3) {
            timeDataValue = timeDataValue
          } else {
            timeDataValue = timeDataValue + ':00'
          }
        } else if (timeType == 2) {
          timeDataValue = dataValue
        } else if (timeType == 3) {
          timeDataValue = this.jnpf.toDate(new Date(), format)
        } else if (timeType == 4) {
          let previousDate = '';
          previousDate = getBeforeTime(timeTarget, timeValue)
          timeDataValue = this.jnpf.toDate(previousDate, format)
        } else if (timeType == 5) {
          let previousDate = '';
          previousDate = getLaterTime(timeTarget, timeValue)
          timeDataValue = this.jnpf.toDate(previousDate, format)
        }
      }
      return timeDataValue;
    },
    dataList() {
      var _data = this.dataForm;
      return _data;
    },
    dataInfo(dataAll) {
      let _dataAll = dataAll
      this.dataForm = _dataAll
      this.isEdit = true
      this.dataAll()
      for (let i = 0; i < _dataAll.fz_learn_example_clickList.length; i++) {
        this.childIndex = i
      }
      for (let i = 0; i < _dataAll.fz_learn_example_taskList.length; i++) {
        this.childIndex = i
      }
      this.childIndex = -1
    },
  },
}

</script>
